<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="reset">重新开始一局游戏</button><br/>
    请输入要猜的数字: <input type="text" id="userGuess">
    <button id="guess">猜</button><br/>
    已经猜的次数: <span id="count"></span><br/>
    结果: <span id="result"></span>

    <script src="js/jquery.min.js"></script>
    <script>
        var number =Math.floor(Math.random() *100) +1;
        console.log("number:"+number);
        //点击猜, 判断猜的对不对, 输出结果
        var count =0;
        $("#guess").click(function(){
            count ++;
            $("#count").text(count);
            var userGuess = $("#userGuess").val();
            
            if(userGuess>number){
                $("#result").text("猜大了");
                $("#result").css("color","red");
            }else if(userGuess<number){
                $("#result").text("猜小了");
                $("#result").css("color","red");
            }else{

                $("#result").text("猜对了");
                $("#result").css("color","blue");
            }
        });

        $("#reset").click(function(){
            number =Math.floor(Math.random() *100) +1;
            console.log("number:"+number);
            count =0;
            $("#count").text("");
            $("#result").text("");
        });


    </script>
</body>
</html>